MSE Full-Link Grayscale Release
This article delves into how Zadig leverages Alibaba Cloud MSE to implement a full-link grayscale release solution, covering the solution's principles, administrator configurations, and practical operations for engineers in their daily use.
# Introduction to the Working Principle

Workflow Description:
MSE Grayscale Release Task
- Copy the YAML of the service in the baseline environment
- Automatically add the suffix
-mse-<grayTag>to themetadata.nameof the resources in the YAML - Automatically add the necessary labels for MSE full-link grayscale release to the resources in the YAML
- Users can set the grayscale image and replica count, and can directly modify other fields in the rendered YAML (labels used during the grayscale process cannot be deleted)
- Generate the grayscale version resources based on the final YAML
Offline MSE Grayscale Service
- Delete all Kubernetes resources with the grayscale label
# Pre-Operations
MSE's full-link grayscale capability can support any K8S cluster. The full-link grayscale scenario requires the construction of gateway capabilities. The following example uses the cloud-native gateway that comes with MSE. Users can choose the appropriate gateway based on their own situation.
# Install the MSE Component
Install the MSE component in an Alibaba Cloud ACK cluster. For installation instructions, refer to the documentation: Install ack-onepilot Component(opens new window).
# Install the MSE Ingress Cloud Native Gateway
For installation instructions, refer to the documentation:
- Create an MSE Cloud Native Gateway(opens new window)
- Access Container Service via MSE Ingress(opens new window)
The following uses services such as spring-a, spring-b, spring-c, and nacos as examples, combined with the MSE cloud-native gateway demonstration project, to illustrate the initialization and MSE grayscale release process.
# Administrators Perform Project Initialization
# Step 1: Create a New Project
Create a new project on Zadig, enter the project name, and select the "K8s YAML" project type.

# Step 2: Create New Services
In the Zadig Service - Production Service module, create the nacos, spring-a, spring-b, and spring-c services and configure the corresponding YAML. For specific configuration, refer to the example project YAML configuration(opens new window).

Warning
In the service deployment, you need to add the following selector and template.metadata.labels:
zadigx-release-version: original
# Step 3: Create a New Environment and Enable MSE
- Create a new production environment on Zadig

- Execute the following command to enable MSE and label the namespace involved in the grayscale process (in the above image: mse-prod) with
mse-enable.
kubectl label namespace <NAMESPACE> mse-enable=enabled
Add the services
spring-a,spring-b,spring-c, andnacosin the production environment.Check if the services are successfully connected to MSE. In the Zadig environment, select a service, such as
spring-a, and check if theone-pilot-initcontaineris successfully injected into the Pod YAML, as shown in the figure below.


# Step 4: Configure the MSE Grayscale Release Workflow
- Create a new release workflow named mse-gray-workflow, add tasks, and configure them as follows.
MSE Grayscale Release: Used to deploy grayscale services- [Optional]
General Task: Used to verify the new version after grayscale Offline MSE Grayscale: Used to offline grayscale services

- Create a new release workflow named prod-workflow, add a
Deploymenttask to execute the production release, and configure it as shown in the figure below.

# Engineer Execution of MSE Grayscale Release
# Multiple Grayscale Service Deployments
Execute mse-gray-workflow , select service components spring-cloud-a and spring-cloud-c , set the grayscale mark, select the corresponding grayscale mirror, number of copies, modify the grayscale service YAML configuration, and click Execute to complete the grayscale service deployment.


Here spring-cloud-a is the traffic entrance, so you need to manually add / Service and MSE Ingress some related fields of the resource in the grayscale service YAML
- Set the grayscale traffic rules through the annotations of MSE Ingress and add a grayscale tag header to the grayscale traffic. The MSE Ingress cloud-native gateway supports configuration in three dimensions: request header, cookie, and weight. Only one of the three can be configured, and if multiple are configured, the effective rules are matched in the order of request header, cookie, and weight
- By Request Header: Traffic segmentation based on Request Header. Add annotations
nginx.ingress.kubernetes.io/canary-by-header,nginx.ingress.kubernetes.io/canary-by-header-value, ornginx.ingress.kubernetes.io/canary-by-header-pattern. - By Cookie: Traffic segmentation based on Cookie. Add annotation
nginx.ingress.kubernetes.io/canary-by-cookie. - By Weight: Set the percentage of requests to the specified service (an integer value between 0 and 100). Add annotation
nginx.ingress.kubernetes.io/canary-weight.
- Set the
backend.service.nameof the grayscale routing rule to the name of the grayscale Service. The specific changes are as follows:
Details
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations: # Add grayscale routing
mse.ingress.kubernetes.io/request-header-control-update: x-mse-tag gray
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-by-header: x-user-id
nginx.ingress.kubernetes.io/canary-by-header-value: "100"
nginx.ingress.kubernetes.io/canary-weight: "0"
creationTimestamp: null
labels:
zadigx-release-service-name: spring-a
zadigx-release-type: mse-gray
zadigx-release-version: gray
name: spring-cloud-a-mse-gray
spec:
ingressClassName: mse
rules:
- host: example.com
http:
paths:
- backend:
service:
name: spring-cloud-a-mse-gray # Modify service configuration
port:
number: 20001
path: /
pathType: Prefix
status:
loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
zadigx-release-service-name: spring-a
zadigx-release-type: mse-gray
zadigx-release-version: gray
name: spring-cloud-a-mse-gray
spec:
ports:
- name: http
port: 20001
protocol: TCP
targetPort: 20001
selector:
app: spring-cloud-a
zadigx-release-service-name: spring-a
zadigx-release-type: mse-gray
zadigx-release-version: gray
status:
loadBalancer: {}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
After deployment, you can view the operating status and basic information of the grayscale service in the production environment.


# Grayscale Result Verification
After the grayscale service is deployed, the new version of the function verification will be automatically performed or verified through other business methods.

# Official Release of Production Services
After verifying that the grayscale service is working correctly, execute the prod-workflow workflow, select the updated service and the corresponding image, and update the production service.


# Grayscale Service Cleanup and Offline
After the production release is successful, execute the mse-gray-workflow workflow, select the grayscale mark to be taken offline, and the corresponding grayscale service will be removed.




